﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;

namespace JY_ajax
{
    /// <summary>
    /// Handler 的摘要说明
    /// </summary>
    public class Handler : IHttpHandler
    {
        protected HttpContext httpContext;
        public void ProcessRequest(HttpContext context)
        {
            context.Response.Buffer = true;
            context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1.0);
            context.Response.AddHeader("pragma", "no-cache");
            context.Response.AddHeader("cache-control", "");
            context.Response.CacheControl = "no-cache";
            context.Response.ContentType = "text/plain";
            this.httpContext = context;
            string text = context.Request.Params["method"];
            if (!string.IsNullOrEmpty(text))
            {
                string s = string.Empty;
                MethodInfo method = base.GetType().GetMethod(text);
                s = method.Invoke(this, null).ToString();
                context.Response.Write(s);
            }
            else
            {
                string message = "Handler页面中无法实现的该方法（" + text + "）";
                context.Response.Write(string.Empty);
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        public string test()
        {
            string a = "[{\"zone\":\"海淀2\"}]";
            return a;
        }
    }
}